﻿Public Class AddRemoveUser_Page
    Public Sub Initialize()
        TextBoxUserId.Text = ""
        PasswordBox1.Password = ""
        PasswordBox2.Password = ""
        ComboBoxLevel.SelectedIndex = 0
        RadioButtonRemove.IsChecked = True
    End Sub

    Private Sub ButtonOK_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonOK.Click
        If RadioButtonAdd.IsChecked Then
            Try
                If PasswordBox1.Password <> PasswordBox2.Password Then
                    MsgBox("两次输入的密码不一致!")
                    Exit Sub
                End If
                If SysManage.usermanage(TextBoxUserId.Text, PasswordBox1.Password, ComboBoxLevel.SelectedIndex) Then
                    MsgBox("添加成功!")
                End If
            Catch err As Exception
                MsgBox(err.Message)
            End Try
        Else
            Try
                If SysManage.usermanage(TextBoxUserId.Text) Then
                    MsgBox("删除成功!")
                End If
            Catch err As Exception
                MsgBox(err.Message)
            End Try
        End If
    End Sub

    Private Sub ButtonReSet_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonReSet.Click
        Initialize
    End Sub

    Private Sub AddRemoveUser_Page_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles Me.KeyDown
        If e.Key = Key.Return Then ButtonOK_Click(sender, New RoutedEventArgs)
    End Sub
End Class
